# -*- coding=UTF-8 -*- 

import MySQLdb
import Config

class MyDb:
	db = MySQLdb.connect(Config.GetDbHost(),Config.GetDbUser(),Config.GetDbPassword(),"Test2017",charset='utf8')
	
	def printVersion(self):
		cursor = self.db.cursor()
		cursor.execute("select version()")
		data = cursor.fetchone()
		print("Database version:%s "% data)
		
	def getTestInfo(self):
		#db2 = MySQLdb.connect("localhost", "lqh", "lqh","Test2017",charset='utf8')
		cursor = self.db.cursor()
		sql = 'SELECT unit_no,channel_id,A.guidPath,testID,A.guidStep, FROM_UNIXTIME(start_time/1000),stepFile FROM chl_test_info A \
			JOIN (SELECT DISTINCT guidStep, stepFile FROM start_test_info) AS B ON A.guidStep=B.guidStep  WHERE unit_no=%s;' % Config.GetCapDevNo() 
		print(sql)
		cursor.execute(sql)
		results = cursor.fetchall()
		return results
		for row in results:
			arg1 = row[0]
			print row[0],row[1],row[2],row[3],row[4],row[5],row[6]

			